﻿package  {
	
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.utils.*;
	import flash.net.*;
	import flash.events.*;
	import flash.display.Bitmap;
	
	
	public class picLoader extends MovieClip {
		
		private var _url:String;
		private var loader:Loader
		public var bitmap:Bitmap;
		private var thisW:Number = 164;
		public var targetIBiao:int;
		public function picLoader() {
			// constructor code
			this.addEventListener(MouseEvent.CLICK, thisCL);
		}
		private function thisCL(e:MouseEvent) {
			trace(this.scaleX,this.scaleY)
		}
		public function setUrl(str:String) {
			_url = str;
			loader = new Loader();
			loader.load(new URLRequest(_url));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
		}
		private function loadCompleteHandler(e:Event):void
		{
			var loaderT:Loader = e.target.loader as Loader;
			//trace(loaderT.width, loaderT.height)
			var bd:BitmapData = new BitmapData(loaderT.width, loaderT.height);
			bd.draw(loaderT)
			bitmap = new Bitmap(bd);
			//bitmap.smoothing = true;
			//bitmap = Bitmap(e.target.content);
			
			if (loaderT.width>loaderT.height) {
				bitmap.width = loaderT.width/loaderT.height*thisW;
				bitmap.height = thisW;
			}else {
				bitmap.height = loaderT.height/loaderT.width*thisW;
				bitmap.width = thisW;
			}
			bitmap.x = -bitmap.width/2;
			bitmap.y = -bitmap.height/2;
			bitmap.smoothing = true;
			addChild(bitmap);
			//mcMask.visible = false;
			bitmap.mask = mcMask;
			
		}
	}
	
}
